package grpc

import (
	pb "bilibi.com/comment/api"
	"bilibi.com/comment/model"
	"context"
	"github.com/golang/protobuf/ptypes/empty"
)

func (s *server) UpdateComment(c context.Context, req *pb.UpdateCommentReq) (*empty.Empty, error) {
	err := s.svr.UpdateComment(c, &model.UpdateComment{
		ID:      req.Id,
		Top:     int8(req.Top),
		Name:    req.Name,
		Message: req.Message,
	})
	if err != nil {
		return nil, err
	}
	return &empty.Empty{}, nil
}

func (s *server) GetComment(c context.Context, req *pb.GetCommentReq) (*pb.GetCommentReply, error) {
	res, err := s.svr.Comment(c, req.Id)
	return &pb.GetCommentReply{Res: res}, err
}
